package test2;


import java.util.Scanner;

import java.util.ArrayList;

import java.util.LinkedHashSet;



public class test2 {

    public static ArrayList<Integer> Union(ArrayList<Integer> list1, ArrayList<Integer> list2) {



        LinkedHashSet<Integer> set = new LinkedHashSet<>();

        set.addAll(list1);

        set.addAll(list2);

        return new ArrayList<>(set);

    }

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        ArrayList<Integer> list1 = new ArrayList<>();

        ArrayList<Integer> list2 = new ArrayList<>();

        ArrayList<Integer> list3 = new ArrayList<>();

        System.out.print("Enter five integers for list1: ");

        for (int i = 0; i < 5; i++) {

            list1.add(scanner.nextInt());

        }



        System.out.print("Enter five integers for list2: ");

        for (int i = 0; i < 5; i++) {

            list2.add(scanner.nextInt());

        }

        list3 = Union(list1, list2);

        System.out.print("The combined list is ");



        for (int i = 0; i < list3.size(); i++) {

            System.out.print(list3.get(i) + " ");



        }



    }

}



